﻿using System;
using System.Collections.Generic;
using System.Text;

using Spring.Transaction.Interceptor;

using efish.Framework.Model;
using efish.Framework.Dao;

namespace efish.Framework.Service
{
    public class NewsService : BaseService, INewsService
    {
        private NewsDAO _newsDAO;
        public NewsDAO NewsDAO
        {
            get
            {
                return _newsDAO;
            }
            set
            {
                _newsDAO = value;
            }
        }

        [Transaction(ReadOnly = false)]
        public void CreateNews(NewsItem item)
        {
            _newsDAO.Save(item);
        }
        [Transaction(ReadOnly = false)]
        public void UpdateNews(NewsItem item)
        {
            _newsDAO.Update(item);
        }
        [Transaction(ReadOnly = false)]
        public void DeleteNews(NewsItem item)
        {
            _newsDAO.Delete(item);
        }
        [Transaction(ReadOnly = false)]
        public void DeleteNewsByID(int id)
        {
            _newsDAO.DeleteByID(id);
        }

        public NewsItem GetNews(int id)
        {
            return _newsDAO.Get(id);
        }
        public IList<NewsItem> GetNewss()
        {
            return _newsDAO.GetAll();
        }
    }

    public interface INewsService
    {
        void CreateNews(NewsItem item);
        void UpdateNews(NewsItem item);
        void DeleteNews(NewsItem item);
        void DeleteNewsByID(int id);

        NewsItem GetNews(int id);
        IList<NewsItem> GetNewss();
    }
}
